package DataCollectionChannel;
use strict;


sub new{
	my $subclass=shift; 	
	my $self = {};
	
	if ( $subclass ) { # if not nill...
      eval " use $subclass; " ;
      die $@ if $@;
      $self= new $subclass;
      $self->{NAME} = undef;					# the company that provides stock data 
      $self->{TIMEOUT} = undef;					# the connection timeout
	  $self->{STATUS} = {
		CODE => "",
		MSG	 => ""
	  };						# the status this channel
	 $self->{DELAY_TIME} = undef;				# the real time of this channel
	 $self->{COLLECTING_DURATION} = undef;					# the collecting data period (in seconds)
	 $self->{PRIORITY} = undef;
	 $self->{BROWSER} = undef;
     bless $self,$subclass;
     return $self;
    } else {
    	
	    $self->{NAME} = undef;					# the company that provides stock data 
		$self->{STOCK_FIELD_FORMAT} = undef;		# stock field format
		$self->{MARKET_FIELD_FORMAT} = undef;		# market field format
		$self->{SECURITY_CENTER_CODE} = undef;		# security center (HoSTC, HaSTC)
		$self->{URL} = undef;						# the address of the data page
		$self->{TIMEOUT} = undef;					# the connection timeout
		$self->{STATUS} = {
			CODE => "",
			MSG	 => ""
		};						# the real time of this channel
		
		$self->{DELAY_TIME}= undef			#
		$self->{COLLECTING_DURATION} = undef;					# the collecting data period (in seconds)
		$self->{PRIORITY} = undef;
		$self->{BROWSER} = undef;
      bless $self; 
      return $self;
    }
} 
###########################
## set/get company code  ##
###########################
sub name{
	my $self = shift;
	if (@_) {$self->{NAME} = $_};
	return $self->{NAME};			
}

################################
## copy	from a hash reference ##
################################
sub copy{
	my $self = shift;
	my $hashref = shift;
	my @self_keys = keys %$hashref;
	foreach my $self_key (@self_keys){
		$self->{uc($self_key)} = $hashref->{lc($self_key)} if not $self->{uc($self_key)};	
	}
}

################################
## set/get stock field format ##
################################
sub stock_field_format{
	my $self = shift;
	if (!@_) {return $self->{STOCK_FIELD_FORMAT}};
	my $field_format = shift;		# the data format array
	$self->{STOCK_FIELD_FORMAT} = $field_format;
}

#################################
## set/get market field format ##
#################################
sub market_field_format{
	my $self = shift;
	if (!@_) {return $self->{MARKET_FIELD_FORMAT}};
	my $field_format = shift;		# the data format array
	$self->{MARKET_FIELD_FORMAT} = $field_format;
}

###########################
## set/get       urls    ##
###########################
sub url{
	my $self = shift;
	if (!@_) {return $self->{URL}};
	my $url = shift;
	$self->{URL} = $url;	
}

###########################
## set/get    timeout    ##
###########################
sub timeout{
	my $self = shift;
	if (!@_) {return $self->{TIMEOUT}};
	my $timeout = shift;
	$self->{TIMEOUT} = $timeout;	
}

###########################
## set/get    status     ##
###########################
sub status{
	my $self = shift;
	if (!@_) {return $self->{STATUS}};
	my $status = shift;
	$self->{STATUS} = $status;	
}


####################################
## set/get  security_center       ## 
####################################
sub security_center_code{
	my $self = shift;
	if (!@_) {return $self->{SECURITY_CENTER_CODE}};
	my $security_center_code = shift;
	$self->{SECURITY_CENTER_CODE} = $security_center_code;
}

##################################################
## get stock info set abtract function			##
##################################################
sub get_stock_info_set{
	
}

##################################################
## get market real time abstract function		##
##################################################
sub get_market_time{
	
}

##################################################
## get market real time abstract function		##
##################################################
sub get_market_status{
	
}

##################################################
## check whether the market is opened			##
##################################################
sub is_market_opened{
	
}




sub DESTROY{
	
}
1;